{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c890e765-c24b-4be3-9da5-dfdf3af45123",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"NpRt5M\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"library\">\n",
       "       if(!window.letsPlotCallQueue) {\n",
       "           window.letsPlotCallQueue = [];\n",
       "       }; \n",
       "       window.letsPlotCall = function(f) {\n",
       "           window.letsPlotCallQueue.push(f);\n",
       "       };\n",
       "       (function() {\n",
       "           var script = document.createElement(\"script\");\n",
       "           script.type = \"text/javascript\";\n",
       "           script.src = \"https://cdn.jsdelivr.net/gh/JetBrains/lets-plot@v4.3.3/js-package/distr/lets-plot.min.js\";\n",
       "           script.onload = function() {\n",
       "               window.letsPlotCall = function(f) {f();};\n",
       "               window.letsPlotCallQueue.forEach(function(f) {f();});\n",
       "               window.letsPlotCallQueue = [];\n",
       "               \n",
       "               \n",
       "           };\n",
       "           script.onerror = function(event) {\n",
       "               window.letsPlotCall = function(f) {};\n",
       "               window.letsPlotCallQueue = [];\n",
       "               var div = document.createElement(\"div\");\n",
       "               div.style.color = 'darkred';\n",
       "               div.textContent = 'Error loading Lets-Plot JS';\n",
       "               document.getElementById(\"NpRt5M\").appendChild(div);\n",
       "           };\n",
       "           var e = document.getElementById(\"NpRt5M\");\n",
       "           e.appendChild(script);\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "Lets-Plot Kotlin API v.4.7.3. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.3.3."
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%useLatestDescriptors\n",
    "%use lets-plot\n",
    "\n",
    "LetsPlot.getInfo()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d0bdc3e7-a806-476f-b485-6c46cc19e290",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"zdkT4c\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"v\":[3.0,1.0,2.0],\n",
       "\"x\":[0.0,1.0,2.0]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"color\":\"v\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"column\":\"v\",\n",
       "\"factor_levels\":[1,2,3,3.0,1.0,2.0]\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"zdkT4c\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val d = mapOf(\n",
    "    \"x\" to listOf(0, 1, 2),\n",
    "    \"v\" to listOf(3, 1, 2),\n",
    ")\n",
    "\n",
    "ggplot(d) + geomPoint { \n",
    "    x = \"x\"; \n",
    "    color = asDiscrete(\"v\", levels=listOf(1, 2, 3))\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6593d289-29d0-4900-89b4-09201f59fb03",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"cMah02\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"library\">\n",
       "       if(!window.letsPlotCallQueue) {\n",
       "           window.letsPlotCallQueue = [];\n",
       "       }; \n",
       "       window.letsPlotCall = function(f) {\n",
       "           window.letsPlotCallQueue.push(f);\n",
       "       };\n",
       "       (function() {\n",
       "           var script = document.createElement(\"script\");\n",
       "           script.type = \"text/javascript\";\n",
       "           script.src = \"https://cdn.jsdelivr.net/gh/JetBrains/lets-plot@v4.3.3/js-package/distr/lets-plot.min.js\";\n",
       "           script.onload = function() {\n",
       "               window.letsPlotCall = function(f) {f();};\n",
       "               window.letsPlotCallQueue.forEach(function(f) {f();});\n",
       "               window.letsPlotCallQueue = [];\n",
       "               \n",
       "               \n",
       "           };\n",
       "           script.onerror = function(event) {\n",
       "               window.letsPlotCall = function(f) {};\n",
       "               window.letsPlotCallQueue = [];\n",
       "               var div = document.createElement(\"div\");\n",
       "               div.style.color = 'darkred';\n",
       "               div.textContent = 'Error loading Lets-Plot JS';\n",
       "               document.getElementById(\"cMah02\").appendChild(div);\n",
       "           };\n",
       "           var e = document.getElementById(\"cMah02\");\n",
       "           e.appendChild(script);\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "   <div id=\"Pe3jAG\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"v\":[3.0,1.0,2.0],\n",
       "\"x\":[0.0,1.0,2.0]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"color\":\"v\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"column\":\"v\",\n",
       "\"factor_levels\":[3.0,2.0,1.0],\n",
       "\"order\":-1\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"Pe3jAG\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%useLatestDescriptors\n",
    "%use lets-plot\n",
    "\n",
    "val d = mapOf(\n",
    "    \"x\" to listOf(0, 1, 2),\n",
    "    \"v\" to listOf(3.0, 1.0, 2.0),\n",
    ")\n",
    "\n",
    "ggplot(d) + geomPoint { \n",
    "    x = \"x\"; \n",
    "    color = asDiscrete(\"v\", levels=listOf(1.0, 2.0, 3.0), order=-1)\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "0eff94c9-942d-4f36-9560-5919082ebf89",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"PJJHFt\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"library\">\n",
       "       if(!window.letsPlotCallQueue) {\n",
       "           window.letsPlotCallQueue = [];\n",
       "       }; \n",
       "       window.letsPlotCall = function(f) {\n",
       "           window.letsPlotCallQueue.push(f);\n",
       "       };\n",
       "       (function() {\n",
       "           var script = document.createElement(\"script\");\n",
       "           script.type = \"text/javascript\";\n",
       "           script.src = \"http://127.0.0.1:8080/js-package/build/dist/js/developmentExecutable/js-package.js\";\n",
       "           script.onload = function() {\n",
       "               window.letsPlotCall = function(f) {f();};\n",
       "               window.letsPlotCallQueue.forEach(function(f) {f();});\n",
       "               window.letsPlotCallQueue = [];\n",
       "               \n",
       "               \n",
       "           };\n",
       "           script.onerror = function(event) {\n",
       "               window.letsPlotCall = function(f) {};\n",
       "               window.letsPlotCallQueue = [];\n",
       "               var div = document.createElement(\"div\");\n",
       "               div.style.color = 'darkred';\n",
       "               div.textContent = 'Error loading Lets-Plot JS';\n",
       "               document.getElementById(\"PJJHFt\").appendChild(div);\n",
       "           };\n",
       "           var e = document.getElementById(\"PJJHFt\");\n",
       "           e.appendChild(script);\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "            <div id=\"kotlin_out_0\"></div>\n",
       "            <script type=\"text/javascript\">\n",
       "                            if(!window.kotlinQueues) {\n",
       "                window.kotlinQueues = {};\n",
       "            }\n",
       "            if(!window.kotlinQueues[\"DataFrame\"]) {\n",
       "                var resQueue = [];\n",
       "                window.kotlinQueues[\"DataFrame\"] = resQueue;\n",
       "                window[\"call_DataFrame\"] = function(f) {\n",
       "                    resQueue.push(f);\n",
       "                }\n",
       "            }\n",
       "            (function (){\n",
       "                var modifiers = [(function(script) {\n",
       "    script.src = \"https://cdn.jsdelivr.net/gh/Kotlin/dataframe@3db46ccccaa1291c0627307d64133317f545e6ae/core/src/main/resources/init.js\"\n",
       "    script.type = \"text/javascript\";\n",
       "})];\n",
       "                var e = document.getElementById(\"kotlin_out_0\");\n",
       "                modifiers.forEach(function (gen) {\n",
       "                    var script = document.createElement(\"script\");\n",
       "                    gen(script)\n",
       "                    script.addEventListener(\"load\", function() {\n",
       "                        window[\"call_DataFrame\"] = function(f) {f();};\n",
       "                        window.kotlinQueues[\"DataFrame\"].forEach(function(f) {f();});\n",
       "                        window.kotlinQueues[\"DataFrame\"] = [];\n",
       "                    }, false);\n",
       "                    script.addEventListener(\"error\", function() {\n",
       "                        window[\"call_DataFrame\"] = function(f) {};\n",
       "                        window.kotlinQueues[\"DataFrame\"] = [];\n",
       "                        var div = document.createElement(\"div\");\n",
       "                        div.style.color = 'darkred';\n",
       "                        div.textContent = 'Error loading resource DataFrame';\n",
       "                        document.getElementById(\"kotlin_out_0\").appendChild(div);\n",
       "                    }, false);\n",
       "                    \n",
       "                    e.appendChild(script);\n",
       "                });\n",
       "            })();\n",
       "            </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "                <style>\n",
       "                :root {\n",
       "    --background: #fff;\n",
       "    --background-odd: #f5f5f5;\n",
       "    --background-hover: #d9edfd;\n",
       "    --header-text-color: #474747;\n",
       "    --text-color: #848484;\n",
       "    --text-color-dark: #000;\n",
       "    --text-color-medium: #737373;\n",
       "    --text-color-pale: #b3b3b3;\n",
       "    --inner-border-color: #aaa;\n",
       "    --bold-border-color: #000;\n",
       "    --link-color: #296eaa;\n",
       "    --link-color-pale: #296eaa;\n",
       "    --link-hover: #1a466c;\n",
       "}\n",
       "\n",
       ":root[theme=\"dark\"], :root [data-jp-theme-light=\"false\"], .dataframe_dark{\n",
       "    --background: #303030;\n",
       "    --background-odd: #3c3c3c;\n",
       "    --background-hover: #464646;\n",
       "    --header-text-color: #dddddd;\n",
       "    --text-color: #b3b3b3;\n",
       "    --text-color-dark: #dddddd;\n",
       "    --text-color-medium: #b2b2b2;\n",
       "    --text-color-pale: #737373;\n",
       "    --inner-border-color: #707070;\n",
       "    --bold-border-color: #777777;\n",
       "    --link-color: #008dc0;\n",
       "    --link-color-pale: #97e1fb;\n",
       "    --link-hover: #00688e;\n",
       "}\n",
       "\n",
       "p.dataframe_description {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe {\n",
       "    font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n",
       "    font-size: 12px;\n",
       "    background-color: var(--background);\n",
       "    color: var(--text-color-dark);\n",
       "    border: none;\n",
       "    border-collapse: collapse;\n",
       "}\n",
       "\n",
       "table.dataframe th, td {\n",
       "    padding: 6px;\n",
       "    border: 1px solid transparent;\n",
       "    text-align: left;\n",
       "}\n",
       "\n",
       "table.dataframe th {\n",
       "    background-color: var(--background);\n",
       "    color: var(--header-text-color);\n",
       "}\n",
       "\n",
       "table.dataframe td {\n",
       "    vertical-align: top;\n",
       "}\n",
       "\n",
       "table.dataframe th.bottomBorder {\n",
       "    border-bottom-color: var(--bold-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(odd) {\n",
       "    background: var(--background-odd);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(even) {\n",
       "    background: var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:hover {\n",
       "    background: var(--background-hover);\n",
       "}\n",
       "\n",
       "table.dataframe a {\n",
       "    cursor: pointer;\n",
       "    color: var(--link-color);\n",
       "    text-decoration: none;\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover > td a {\n",
       "    color: var(--link-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe a:hover {\n",
       "    color: var(--link-hover);\n",
       "    text-decoration: underline;\n",
       "}\n",
       "\n",
       "table.dataframe img {\n",
       "    max-width: fit-content;\n",
       "}\n",
       "\n",
       "table.dataframe th.complex {\n",
       "    background-color: var(--background);\n",
       "    border: 1px solid var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe .leftBorder {\n",
       "    border-left-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightBorder {\n",
       "    border-right-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightAlign {\n",
       "    text-align: right;\n",
       "}\n",
       "\n",
       "table.dataframe .expanderSvg {\n",
       "    width: 8px;\n",
       "    height: 8px;\n",
       "    margin-right: 3px;\n",
       "}\n",
       "\n",
       "table.dataframe .expander {\n",
       "    display: flex;\n",
       "    align-items: center;\n",
       "}\n",
       "\n",
       "/* formatting */\n",
       "\n",
       "table.dataframe .null {\n",
       "    color: var(--text-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe .structural {\n",
       "    color: var(--text-color-medium);\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .dataFrameCaption {\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .numbers {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe td:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "\n",
       "                </style>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "//%useLatestDescriptors\n",
    "//%use lets-plot\n",
    "%use @/home/ikupriyanov/Projects/lets-plot-kotlin/lets-plot-dev.json\n",
    "\n",
    "%use dataframe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e1354eed-d9b4-4ce9-b5df-77fe97bd09ee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Current classpath (156 paths):\n",
       "/home/ikupriyanov/Applications/miniconda3/envs/lets-plot-python-module/lib/python3.8/site-packages/run_kotlin_kernel/jars/lib-0.12.0-217.jar\n",
       "/home/ikupriyanov/Applications/miniconda3/envs/lets-plot-python-module/lib/python3.8/site-packages/run_kotlin_kernel/jars/api-0.12.0-217.jar\n",
       "/home/ikupriyanov/Applications/miniconda3/envs/lets-plot-python-module/lib/python3.8/site-packages/run_kotlin_kernel/jars/kotlin-script-runtime-1.9.23.jar\n",
       "/home/ikupriyanov/Applications/miniconda3/envs/lets-plot-python-module/lib/python3.8/site-packages/run_kotlin_kernel/jars/kotlin-reflect-1.9.23.jar\n",
       "/home/ikupriyanov/Applications/miniconda3/envs/lets-plot-python-module/lib/python3.8/site-packages/run_kotlin_kernel/jars/kotlin-stdlib-1.9.23.jar\n",
       "/home/ikupriyanov/Applications/miniconda3/envs/lets-plot-python-module/lib/python3.8/site-packages/run_kotlin_kernel/jars/kotlinx-serialization-json-jvm-1.6.3.jar\n",
       "/home/ikupriyanov/Applications/miniconda3/envs/lets-plot-python-module/lib/python3.8/site-packages/run_kotlin_kernel/jars/kotlinx-serialization-core-jvm-1.6.3.jar\n",
       "/home/ikupriyanov/Applications/miniconda3/envs/lets-plot-python-module/lib/python3.8/site-packages/run_kotlin_kernel/jars/annotations-13.0.jar\n",
       "/home/ikupriyanov/.m2/repository/io/github/microutils/kotlin-logging-jvm/2.0.5/kotlin-logging-jvm-2.0.5.jar\n",
       "/home/ikupriyanov/.m2/repository/org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.4.31/kotlin-stdlib-1.4.31.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.31/kotlin-stdlib-common-1.4.31.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/lets-plot-common/4.3.3/lets-plot-common-4.3.3.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/commons-jvm/4.3.3/commons-jvm-4.3.3.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/datamodel-jvm/4.3.3/datamodel-jvm-4.3.3.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/plot-base-jvm/4.3.3/plot-base-jvm-4.3.3.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/plot-builder-jvm/4.3.3/plot-builder-jvm-4.3.3.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/plot-stem-jvm/4.3.3/plot-stem-jvm-4.3.3.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/deprecated-in-v4-jvm/4.3.3/deprecated-in-v4-jvm-4.3.3.jar\n",
       "/home/ikupriyanov/.m2/repository/io/github/microutils/kotlin-logging/2.0.5/kotlin-logging-2.0.5.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/lets-plot-image-export/4.3.3/lets-plot-image-export-4.3.3.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-transcoder/1.17/batik-transcoder-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-anim/1.17/batik-anim-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-css/1.17/batik-css-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-ext/1.17/batik-ext-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-parser/1.17/batik-parser-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-svg-dom/1.17/batik-svg-dom-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-awt-util/1.17/batik-awt-util-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/xmlgraphics-commons/2.9/xmlgraphics-commons-2.9.jar\n",
       "/home/ikupriyanov/.m2/repository/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar\n",
       "/home/ikupriyanov/.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-bridge/1.17/batik-bridge-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-script/1.17/batik-script-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-dom/1.17/batik-dom-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/xml-apis/xml-apis/1.4.01/xml-apis-1.4.01.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-gvt/1.17/batik-gvt-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-shared-resources/1.17/batik-shared-resources-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-svggen/1.17/batik-svggen-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-util/1.17/batik-util-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-constants/1.17/batik-constants-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-i18n/1.17/batik-i18n-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-xml/1.17/batik-xml-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/xml-apis/xml-apis-ext/1.3.04/xml-apis-ext-1.3.04.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlgraphics/batik-codec/1.17/batik-codec-1.17.jar\n",
       "/home/ikupriyanov/.m2/repository/com/twelvemonkeys/imageio/imageio-tiff/3.8.1/imageio-tiff-3.8.1.jar\n",
       "/home/ikupriyanov/.m2/repository/com/twelvemonkeys/imageio/imageio-core/3.8.1/imageio-core-3.8.1.jar\n",
       "/home/ikupriyanov/.m2/repository/com/twelvemonkeys/imageio/imageio-metadata/3.8.1/imageio-metadata-3.8.1.jar\n",
       "/home/ikupriyanov/.m2/repository/com/twelvemonkeys/common/common-lang/3.8.1/common-lang-3.8.1.jar\n",
       "/home/ikupriyanov/.m2/repository/com/twelvemonkeys/common/common-io/3.8.1/common-io-3.8.1.jar\n",
       "/home/ikupriyanov/.m2/repository/com/twelvemonkeys/common/common-image/3.8.1/common-image-3.8.1.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/platf-awt/4.3.3/platf-awt-4.3.3.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/lets-plot-kotlin-kernel/4.7.3/lets-plot-kotlin-kernel-4.7.3.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/platf-awt-jvm/4.3.3/platf-awt-jvm-4.3.3.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/lets-plot-common/0.0.0-SNAPSHOT/lets-plot-common-0.0.0-SNAPSHOT.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/commons-jvm/0.0.0-SNAPSHOT/commons-jvm-0.0.0-SNAPSHOT.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.7.1/kotlinx-coroutines-core-jvm-1.7.1.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.8.20/kotlin-stdlib-jdk8-1.8.20.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.8.20/kotlin-stdlib-jdk7-1.8.20.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/datamodel-jvm/0.0.0-SNAPSHOT/datamodel-jvm-0.0.0-SNAPSHOT.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/plot-base-jvm/0.0.0-SNAPSHOT/plot-base-jvm-0.0.0-SNAPSHOT.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/plot-builder-jvm/0.0.0-SNAPSHOT/plot-builder-jvm-0.0.0-SNAPSHOT.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/plot-stem-jvm/0.0.0-SNAPSHOT/plot-stem-jvm-0.0.0-SNAPSHOT.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/deprecated-in-v4-jvm/0.0.0-SNAPSHOT/deprecated-in-v4-jvm-0.0.0-SNAPSHOT.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/lets-plot-image-export/0.0.0-SNAPSHOT/lets-plot-image-export-0.0.0-SNAPSHOT.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/platf-awt/0.0.0-SNAPSHOT/platf-awt-0.0.0-SNAPSHOT.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/lets-plot-kotlin-kernel/0.0.0-SNAPSHOT/lets-plot-kotlin-kernel-0.0.0-SNAPSHOT.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/lets-plot/platf-awt-jvm/0.0.0-SNAPSHOT/platf-awt-jvm-0.0.0-SNAPSHOT.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlinx/dataframe/0.13.1/dataframe-0.13.1.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlinx/dataframe-core/0.13.1/dataframe-core-0.13.1.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.9.22/kotlin-reflect-1.9.22.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/commons/commons-csv/1.10.0/commons-csv-1.10.0.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlinx/kotlinx-datetime-jvm/0.5.0/kotlinx-datetime-jvm-0.5.0.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.9.22/kotlin-stdlib-jdk8-1.9.22.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.9.22/kotlin-stdlib-jdk7-1.9.22.jar\n",
       "/home/ikupriyanov/.m2/repository/com/beust/klaxon/5.5/klaxon-5.5.jar\n",
       "/home/ikupriyanov/.m2/repository/com/github/kittinunf/fuel/fuel/2.3.1/fuel-2.3.1.jar\n",
       "/home/ikupriyanov/.m2/repository/com/github/kittinunf/result/result/3.1.0/result-3.1.0.jar\n",
       "/home/ikupriyanov/.m2/repository/com/squareup/kotlinpoet-jvm/1.16.0/kotlinpoet-jvm-1.16.0.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlinx/dataframe-arrow/0.13.1/dataframe-arrow-0.13.1.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/arrow/arrow-vector/15.0.0/arrow-vector-15.0.0.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/arrow/arrow-memory-core/15.0.0/arrow-memory-core-15.0.0.jar\n",
       "/home/ikupriyanov/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar\n",
       "/home/ikupriyanov/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.16.0/jackson-core-2.16.0.jar\n",
       "/home/ikupriyanov/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.16.0/jackson-annotations-2.16.0.jar\n",
       "/home/ikupriyanov/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.16.0/jackson-databind-2.16.0.jar\n",
       "/home/ikupriyanov/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.16.0/jackson-datatype-jsr310-2.16.0.jar\n",
       "/home/ikupriyanov/.m2/repository/commons-codec/commons-codec/1.15/commons-codec-1.15.jar\n",
       "/home/ikupriyanov/.m2/repository/com/google/flatbuffers/flatbuffers-java/23.5.26/flatbuffers-java-23.5.26.jar\n",
       "/home/ikupriyanov/.m2/repository/org/slf4j/slf4j-api/2.0.9/slf4j-api-2.0.9.jar\n",
       "/home/ikupriyanov/.m2/repository/org/eclipse/collections/eclipse-collections/11.1.0/eclipse-collections-11.1.0.jar\n",
       "/home/ikupriyanov/.m2/repository/org/eclipse/collections/eclipse-collections-api/11.1.0/eclipse-collections-api-11.1.0.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/arrow/arrow-format/15.0.0/arrow-format-15.0.0.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/arrow/arrow-memory-unsafe/15.0.0/arrow-memory-unsafe-15.0.0.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/commons/commons-compress/1.26.0/commons-compress-1.26.0.jar\n",
       "/home/ikupriyanov/.m2/repository/commons-io/commons-io/2.15.1/commons-io-2.15.1.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/commons/commons-lang3/3.14.0/commons-lang3-3.14.0.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlinx/dataframe-excel/0.13.1/dataframe-excel-0.13.1.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/poi/poi/5.2.5/poi-5.2.5.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/commons/commons-collections4/4.4/commons-collections4-4.4.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.jar\n",
       "/home/ikupriyanov/.m2/repository/com/zaxxer/SparseBitSet/1.3/SparseBitSet-1.3.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/logging/log4j/log4j-api/2.21.1/log4j-api-2.21.1.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/poi/poi-ooxml/5.2.5/poi-ooxml-5.2.5.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/poi/poi-ooxml-lite/5.2.5/poi-ooxml-lite-5.2.5.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/xmlbeans/xmlbeans/5.2.0/xmlbeans-5.2.0.jar\n",
       "/home/ikupriyanov/.m2/repository/com/github/virtuald/curvesapi/1.08/curvesapi-1.08.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlinx/dataframe-openapi/0.13.1/dataframe-openapi-0.13.1.jar\n",
       "/home/ikupriyanov/.m2/repository/io/swagger/parser/v3/swagger-parser/2.1.20/swagger-parser-2.1.20.jar\n",
       "/home/ikupriyanov/.m2/repository/io/swagger/parser/v3/swagger-parser-v2-converter/2.1.20/swagger-parser-v2-converter-2.1.20.jar\n",
       "/home/ikupriyanov/.m2/repository/io/swagger/swagger-core/1.6.12/swagger-core-1.6.12.jar\n",
       "/home/ikupriyanov/.m2/repository/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar\n",
       "/home/ikupriyanov/.m2/repository/jakarta/activation/jakarta.activation-api/1.2.2/jakarta.activation-api-1.2.2.jar\n",
       "/home/ikupriyanov/.m2/repository/io/swagger/swagger-models/1.6.12/swagger-models-1.6.12.jar\n",
       "/home/ikupriyanov/.m2/repository/io/swagger/swagger-annotations/1.6.12/swagger-annotations-1.6.12.jar\n",
       "/home/ikupriyanov/.m2/repository/com/google/guava/guava/32.1.3-android/guava-32.1.3-android.jar\n",
       "/home/ikupriyanov/.m2/repository/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar\n",
       "/home/ikupriyanov/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar\n",
       "/home/ikupriyanov/.m2/repository/com/google/j2objc/j2objc-annotations/2.8/j2objc-annotations-2.8.jar\n",
       "/home/ikupriyanov/.m2/repository/io/swagger/swagger-parser/1.0.69/swagger-parser-1.0.69.jar\n",
       "/home/ikupriyanov/.m2/repository/io/swagger/swagger-parser-safe-url-resolver/1.0.69/swagger-parser-safe-url-resolver-1.0.69.jar\n",
       "/home/ikupriyanov/.m2/repository/io/swagger/swagger-compat-spec-parser/1.0.69/swagger-compat-spec-parser-1.0.69.jar\n",
       "/home/ikupriyanov/.m2/repository/com/github/java-json-tools/json-schema-validator/2.2.14/json-schema-validator-2.2.14.jar\n",
       "/home/ikupriyanov/.m2/repository/com/github/java-json-tools/jackson-coreutils-equivalence/1.0/jackson-coreutils-equivalence-1.0.jar\n",
       "/home/ikupriyanov/.m2/repository/com/github/java-json-tools/json-schema-core/1.2.14/json-schema-core-1.2.14.jar\n",
       "/home/ikupriyanov/.m2/repository/com/github/java-json-tools/uri-template/0.10/uri-template-0.10.jar\n",
       "/home/ikupriyanov/.m2/repository/org/mozilla/rhino/1.7.7.2/rhino-1.7.7.2.jar\n",
       "/home/ikupriyanov/.m2/repository/joda-time/joda-time/2.10.5/joda-time-2.10.5.jar\n",
       "/home/ikupriyanov/.m2/repository/com/googlecode/libphonenumber/libphonenumber/8.11.1/libphonenumber-8.11.1.jar\n",
       "/home/ikupriyanov/.m2/repository/net/sf/jopt-simple/jopt-simple/5.0.4/jopt-simple-5.0.4.jar\n",
       "/home/ikupriyanov/.m2/repository/com/github/java-json-tools/json-patch/1.13/json-patch-1.13.jar\n",
       "/home/ikupriyanov/.m2/repository/com/github/java-json-tools/msg-simple/1.2/msg-simple-1.2.jar\n",
       "/home/ikupriyanov/.m2/repository/com/github/java-json-tools/btf/1.3/btf-1.3.jar\n",
       "/home/ikupriyanov/.m2/repository/com/github/java-json-tools/jackson-coreutils/2.0/jackson-coreutils-2.0.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/httpcomponents/httpclient/4.5.14/httpclient-4.5.14.jar\n",
       "/home/ikupriyanov/.m2/repository/org/apache/httpcomponents/httpcore/4.4.16/httpcore-4.4.16.jar\n",
       "/home/ikupriyanov/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar\n",
       "/home/ikupriyanov/.m2/repository/io/swagger/core/v3/swagger-models/2.2.20/swagger-models-2.2.20.jar\n",
       "/home/ikupriyanov/.m2/repository/io/swagger/parser/v3/swagger-parser-core/2.1.20/swagger-parser-core-2.1.20.jar\n",
       "/home/ikupriyanov/.m2/repository/io/swagger/parser/v3/swagger-parser-v3/2.1.20/swagger-parser-v3-2.1.20.jar\n",
       "/home/ikupriyanov/.m2/repository/io/swagger/core/v3/swagger-core/2.2.20/swagger-core-2.2.20.jar\n",
       "/home/ikupriyanov/.m2/repository/io/swagger/core/v3/swagger-annotations/2.2.20/swagger-annotations-2.2.20.jar\n",
       "/home/ikupriyanov/.m2/repository/io/swagger/parser/v3/swagger-parser-safe-url-resolver/2.1.20/swagger-parser-safe-url-resolver-2.1.20.jar\n",
       "/home/ikupriyanov/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-yaml/2.16.1/jackson-dataformat-yaml-2.16.1.jar\n",
       "/home/ikupriyanov/.m2/repository/org/yaml/snakeyaml/2.2/snakeyaml-2.2.jar\n",
       "/home/ikupriyanov/.m2/repository/io/github/oshai/kotlin-logging-jvm/6.0.3/kotlin-logging-jvm-6.0.3.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlinx/dataframe-jdbc/0.13.1/dataframe-jdbc-0.13.1.jar\n",
       "/home/ikupriyanov/.m2/repository/org/mariadb/jdbc/mariadb-java-client/3.3.2/mariadb-java-client-3.3.2.jar\n",
       "/home/ikupriyanov/.m2/repository/com/github/waffle/waffle-jna/3.3.0/waffle-jna-3.3.0.jar\n",
       "/home/ikupriyanov/.m2/repository/net/java/dev/jna/jna/5.13.0/jna-5.13.0.jar\n",
       "/home/ikupriyanov/.m2/repository/net/java/dev/jna/jna-platform/5.13.0/jna-platform-5.13.0.jar\n",
       "/home/ikupriyanov/.m2/repository/org/slf4j/jcl-over-slf4j/2.0.7/jcl-over-slf4j-2.0.7.jar\n",
       "/home/ikupriyanov/.m2/repository/com/github/ben-manes/caffeine/caffeine/2.9.3/caffeine-2.9.3.jar\n",
       "/home/ikupriyanov/.m2/repository/com/google/errorprone/error_prone_annotations/2.10.0/error_prone_annotations-2.10.0.jar\n",
       "/home/ikupriyanov/.m2/repository/org/checkerframework/checker-qual/3.32.0/checker-qual-3.32.0.jar\n",
       "/home/ikupriyanov/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.9.22/kotlin-stdlib-1.9.22.jar"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ":classpath"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "38dde32b-aae6-4242-90d1-27034a97d8ed",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Line_34.jupyter.kts (8:1 - 2) Unresolved reference: p"
     ]
    }
   ],
   "source": [
    "val d = mapOf(\n",
    "    \"x\" to listOf(0, 1, 2),\n",
    "    \"v\" to listOf(3, 1, 2),\n",
    "    \"o\" to listOf(5, 6, 4), // easy to catch - 3 in a middle\n",
    "\n",
    ")\n",
    "\n",
    "p + \n",
    "    geomPoint { x=\"x\"; color=asDiscrete(\"v\", levels=listOf(1, 2, 3), order=-1)} + \n",
    "    ggtitle(\"\"\"levels=listOf(1, 2, 3), order=-1\"\"\")  + ggsize(400, 400)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "14dceae5-accf-40be-82e4-9c40cb50025a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"vguJbg\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"Default\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"v\":[3.0,1.0,2.0],\n",
       "\"x\":[0.0,1.0,2.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":300.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"color\":\"v\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"asDiscrete(\\\"v\\\")\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"v\":[3.0,1.0,2.0],\n",
       "\"x\":[0.0,1.0,2.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":300.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"color\":\"v\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"mapping_annotations\":[{\n",
       "\"aes\":\"color\",\n",
       "\"annotation\":\"as_discrete\",\n",
       "\"parameters\":{\n",
       "\"label\":\"v\"\n",
       "}\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "}],\n",
       "\"ggsize\":{\n",
       "\"width\":600.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"vguJbg\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val p = ggplot(d) + ggsize(300, 200)\n",
    "\n",
    "gggrid(listOf(\n",
    "    p + geomPoint{ x=\"x\"; color=\"v\" } + ggtitle(\"Default\"),\n",
    "    p + geomPoint{ x=\"x\"; color=asDiscrete(\"v\") } + ggtitle(\"\"\"asDiscrete(\"v\")\"\"\")\n",
    ")) + ggsize(600, 200)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "89b791ab-5866-4790-bffb-a006ecc02096",
   "metadata": {},
   "source": [
    "Single order option"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "dabe2f6d-2edb-4f8e-8e49-dd597422bdac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"jl12XA\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":3,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"levels=listOf(1, 2, 3)\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"v\":[3.0,1.0,2.0],\n",
       "\"x\":[0.0,1.0,2.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":300.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"color\":\"v\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"column\":\"v\",\n",
       "\"factor_levels\":[1,2,3,3.0,1.0,2.0]\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"order=-1\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"v\":[3.0,1.0,2.0],\n",
       "\"x\":[0.0,1.0,2.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":300.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"color\":\"v\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"mapping_annotations\":[{\n",
       "\"aes\":\"color\",\n",
       "\"annotation\":\"as_discrete\",\n",
       "\"parameters\":{\n",
       "\"label\":\"v\",\n",
       "\"order\":-1\n",
       "}\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"order_by='o'\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"v\":[3.0,1.0,2.0],\n",
       "\"x\":[0.0,1.0,2.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":300.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"color\":\"v\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"mapping_annotations\":[{\n",
       "\"aes\":\"color\",\n",
       "\"annotation\":\"as_discrete\",\n",
       "\"parameters\":{\n",
       "\"label\":\"v\",\n",
       "\"order_by\":\"o\"\n",
       "}\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "}],\n",
       "\"ggsize\":{\n",
       "\"width\":1000.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"jl12XA\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gggrid(listOf(\n",
    "    p + geomPoint { x=\"x\"; color=asDiscrete(\"v\", levels=listOf(1, 2, 3))} + ggtitle(\"levels=listOf(1, 2, 3)\"),\n",
    "    p + geomPoint { x=\"x\"; color=asDiscrete(\"v\", order=-1)} + ggtitle(\"order=-1\"),\n",
    "    p + geomPoint { x=\"x\"; color=asDiscrete(\"v\", orderBy=\"o\")} + ggtitle(\"order_by='o'\"),\n",
    ")) + ggsize(1000, 200)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7d239cbd-44af-4149-8c8a-24fd1129c155",
   "metadata": {},
   "source": [
    "orderBy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "2423923c-86c4-47e7-8c12-284ef4ceb493",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"hC6pQa\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"orderBy=\\\"o\\\", order=-1\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"v\":[3.0,1.0,2.0],\n",
       "\"x\":[0.0,1.0,2.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":300.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"color\":\"v\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"mapping_annotations\":[{\n",
       "\"aes\":\"color\",\n",
       "\"annotation\":\"as_discrete\",\n",
       "\"parameters\":{\n",
       "\"label\":\"v\",\n",
       "\"order_by\":\"o\",\n",
       "\"order\":-1\n",
       "}\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"orderBy=\\\"o\\\", order=1\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"v\":[3.0,1.0,2.0],\n",
       "\"x\":[0.0,1.0,2.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":300.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"color\":\"v\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"mapping_annotations\":[{\n",
       "\"aes\":\"color\",\n",
       "\"annotation\":\"as_discrete\",\n",
       "\"parameters\":{\n",
       "\"label\":\"v\",\n",
       "\"order_by\":\"o\",\n",
       "\"order\":1\n",
       "}\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "}],\n",
       "\"ggsize\":{\n",
       "\"width\":600.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"hC6pQa\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gggrid(listOf(\n",
    "    p + geomPoint { x=\"x\"; color=asDiscrete(\"v\", orderBy=\"o\", order=-1) } + ggtitle(\"\"\"orderBy=\"o\", order=-1\"\"\"),\n",
    "    p + geomPoint { x=\"x\"; color=asDiscrete(\"v\", orderBy=\"o\", order=1) } + ggtitle(\"\"\"orderBy=\"o\", order=1\"\"\"),\n",
    ")) + ggsize(600, 200)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a81a0ca6-577b-471a-a5f3-140e9c1ba08d",
   "metadata": {},
   "source": [
    "Order with levels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "b0d37c26-d5d8-48e1-b215-ae7cd61652c4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"sNXF9U\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"ggtitle\":{\n",
       "\"text\":\"levels=listOf(1, 2, 3), order=-1\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"v\":[3.0,1.0,2.0],\n",
       "\"x\":[0.0,1.0,2.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":800.0,\n",
       "\"height\":600.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"color\":\"v\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"column\":\"v\",\n",
       "\"factor_levels\":[3.0,2.0,1.0],\n",
       "\"order\":-1\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"sNXF9U\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p + geomPoint { x=\"x\"; color=asDiscrete(\"v\", levels=listOf(1.0, 2.0, 3.0), order=-1)} + ggtitle(\"\"\"levels=listOf(1, 2, 3), order=-1\"\"\")  + ggsize(800, 600)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "05e709be-82fe-4035-8e7f-d1a5e2687bf9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"oNI0ew\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"levels=listOf(1, 2, 3), order=-1\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"v\":[3.0,1.0,2.0],\n",
       "\"x\":[0.0,1.0,2.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":300.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"color\":\"v\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"column\":\"v\",\n",
       "\"factor_levels\":[2.0,1.0,3.0,3,2,1],\n",
       "\"order\":-1\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"levels=listOf(1, 2, 3), orderBy=\\\"o\\\"\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"v\":[3.0,1.0,2.0],\n",
       "\"x\":[0.0,1.0,2.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":300.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"color\":\"v\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"column\":\"v\",\n",
       "\"factor_levels\":[1,2,3,3.0,1.0,2.0]\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "}],\n",
       "\"ggsize\":{\n",
       "\"width\":600.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"oNI0ew\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gggrid(listOf(\n",
    "    p + geomPoint { x=\"x\"; color=asDiscrete(\"v\", levels=listOf(1, 2, 3), order=-1)} + ggtitle(\"\"\"levels=listOf(1, 2, 3), order=-1\"\"\"),\n",
    "    p + geomPoint { x=\"x\"; color=asDiscrete(\"v\", levels=listOf(1, 2, 3), orderBy=\"o\")} + ggtitle(\"\"\"levels=listOf(1, 2, 3), orderBy=\"o\"\"\"\"),\n",
    ")) + ggsize(600, 200)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a40be108-d598-4da6-ba23-754a49349ce3",
   "metadata": {},
   "source": [
    "Label"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "5f985ff6-f620-4fa0-bd93-4c159eb53ecd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"tuFMmV\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"label=VVV\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"v\":[3.0,1.0,2.0],\n",
       "\"x\":[0.0,1.0,2.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":300.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"color\":\"v\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"mapping_annotations\":[{\n",
       "\"aes\":\"color\",\n",
       "\"annotation\":\"as_discrete\",\n",
       "\"parameters\":{\n",
       "\"label\":\"VVV\"\n",
       "}\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "},{\n",
       "\"ggtitle\":{\n",
       "\"text\":\"levels=listOf(1, 2, 3), label=VVV\"\n",
       "},\n",
       "\"mapping\":{\n",
       "},\n",
       "\"data\":{\n",
       "\"v\":[3.0,1.0,2.0],\n",
       "\"x\":[0.0,1.0,2.0]\n",
       "},\n",
       "\"ggsize\":{\n",
       "\"width\":300.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"color\":\"v\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"column\":\"v\",\n",
       "\"factor_levels\":[1,2,3,3.0,1.0,2.0]\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "}],\n",
       "\"ggsize\":{\n",
       "\"width\":600.0,\n",
       "\"height\":200.0\n",
       "},\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"tuFMmV\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gggrid(listOf(\n",
    "    p + geomPoint { x=\"x\"; color=asDiscrete(\"v\", label=\"VVV\")} + ggtitle(\"label=VVV\"),\n",
    "    p + geomPoint { x=\"x\"; color=asDiscrete(\"v\", levels=listOf(1, 2, 3), label=\"VVV\")} + ggtitle(\"levels=listOf(1, 2, 3), label=VVV\")\n",
    ")) + ggsize(600, 200)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c3b856ab-cc98-4d77-9695-0ce1c8a8ae1c",
   "metadata": {},
   "source": [
    "Grouping"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "36c07a52-4cf4-499d-b394-6ca6845ccedb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"FJtQc0\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\"\n",
       "},\n",
       "\"data\":{\n",
       "\"a\":[0.0,0.0,1.0,1.0],\n",
       "\"x\":[0.0,5.0,10.0,15.0],\n",
       "\"y\":[0.0,5.0,10.0,15.0]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"color\":\"a\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"size\":3.0,\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"line\",\n",
       "\"data_meta\":{\n",
       "\"mapping_annotations\":[{\n",
       "\"aes\":\"color\",\n",
       "\"annotation\":\"as_discrete\",\n",
       "\"parameters\":{\n",
       "\"label\":\"a\"\n",
       "}\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"FJtQc0\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val df = mapOf(\n",
    "    \"x\" to listOf(0, 5, 10, 15),\n",
    "    \"y\" to listOf(0, 5, 10, 15),\n",
    "    \"a\" to listOf(0, 0, 1, 1),\n",
    "    \"c\" to listOf('a', 'a', 'b', 'b'),\n",
    ")\n",
    "\n",
    "ggplot(df) { x=\"x\"; y=\"y\" } + geomLine(size=3) { color=asDiscrete(\"a\") }"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ab4f6d63-897a-4e90-a9b2-2ee6661a0839",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"F23Qvp\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "\"x\":\"displ\",\n",
       "\"y\":\"hwy\"\n",
       "},\n",
       "\"data\":{\n",
       "\"cyl\":[8.0,8.0,8.0,4.0,4.0,4.0,5.0,5.0,5.0,6.0,6.0,6.0],\n",
       "\"displ\":[11.0,12.0,13.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0],\n",
       "\"hwy\":[27.0,25.0,23.0,45.0,43.0,41.0,39.0,37.0,35.0,33.0,31.0,29.0]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"color\":\"cyl\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"mapping_annotations\":[{\n",
       "\"aes\":\"color\",\n",
       "\"annotation\":\"as_discrete\",\n",
       "\"parameters\":{\n",
       "\"label\":\"cyl\"\n",
       "}\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "\"color\":\"cyl\"\n",
       "},\n",
       "\"stat\":\"smooth\",\n",
       "\"se\":false,\n",
       "\"size\":1.0,\n",
       "\"method\":\"lm\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"smooth\",\n",
       "\"data_meta\":{\n",
       "\"mapping_annotations\":[{\n",
       "\"aes\":\"color\",\n",
       "\"annotation\":\"as_discrete\",\n",
       "\"parameters\":{\n",
       "\"label\":\"cyl\"\n",
       "}\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "\"cyl\":[8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0],\n",
       "\"displ\":[11.0,11.025316455696203,11.050632911392405,11.075949367088608,11.10126582278481,11.126582278481013,11.151898734177216,11.177215189873417,11.20253164556962,11.227848101265822,11.253164556962025,11.278481012658228,11.30379746835443,11.329113924050633,11.354430379746836,11.379746835443038,11.405063291139241,11.430379746835444,11.455696202531646,11.481012658227849,11.50632911392405,11.531645569620252,11.556962025316455,11.582278481012658,11.60759493670886,11.632911392405063,11.658227848101266,11.683544303797468,11.708860759493671,11.734177215189874,11.759493670886076,11.784810126582279,11.810126582278482,11.835443037974684,11.860759493670885,11.886075949367088,11.91139240506329,11.936708860759493,11.962025316455696,11.987341772151899,12.012658227848101,12.037974683544304,12.063291139240507,12.08860759493671,12.113924050632912,12.139240506329115,12.164556962025316,12.189873417721518,12.215189873417721,12.240506329113924,12.265822784810126,12.291139240506329,12.316455696202532,12.341772151898734,12.367088607594937,12.39240506329114,12.417721518987342,12.443037974683545,12.468354430379748,12.49367088607595,12.518987341772151,12.544303797468354,12.569620253164556,12.594936708860759,12.620253164556962,12.645569620253164,12.670886075949367,12.69620253164557,12.721518987341772,12.746835443037975,12.772151898734178,12.79746835443038,12.822784810126581,12.848101265822784,12.873417721518987,12.89873417721519,12.924050632911392,12.949367088607595,12.974683544303797,13.0,2.0,2.0253164556962027,2.050632911392405,2.0759493670886076,2.1012658227848102,2.1265822784810124,2.151898734177215,2.1772151898734178,2.2025316455696204,2.2278481012658227,2.2531645569620253,2.278481012658228,2.3037974683544302,2.329113924050633,2.3544303797468356,2.3797468354430378,2.4050632911392404,2.430379746835443,2.4556962025316453,2.481012658227848,2.5063291139240507,2.5316455696202533,2.5569620253164556,2.5822784810126582,2.607594936708861,2.632911392405063,2.6582278481012658,2.6835443037974684,2.708860759493671,2.7341772151898733,2.759493670886076,2.7848101265822782,2.810126582278481,2.8354430379746836,2.8607594936708862,2.8860759493670884,2.911392405063291,2.9367088607594938,2.962025316455696,2.9873417721518987,3.0126582278481013,3.037974683544304,3.0632911392405062,3.088607594936709,3.113924050632911,3.1392405063291138,3.1645569620253164,3.189873417721519,3.2151898734177218,3.240506329113924,3.2658227848101267,3.291139240506329,3.3164556962025316,3.3417721518987342,3.367088607594937,3.392405063291139,3.4177215189873418,3.443037974683544,3.4683544303797467,3.4936708860759493,3.518987341772152,3.5443037974683547,3.569620253164557,3.5949367088607596,3.620253164556962,3.6455696202531644,3.670886075949367,3.6962025316455698,3.7215189873417724,3.7468354430379747,3.772151898734177,3.7974683544303796,3.8227848101265822,3.848101265822785,3.8734177215189876,3.8987341772151898,3.9240506329113924,3.9493670886075947,3.9746835443037973,4.0,5.0,5.025316455696203,5.050632911392405,5.075949367088608,5.10126582278481,5.1265822784810124,5.151898734177215,5.177215189873418,5.2025316455696204,5.227848101265823,5.253164556962025,5.2784810126582276,5.30379746835443,5.329113924050633,5.3544303797468356,5.379746835443038,5.405063291139241,5.430379746835443,5.455696202531645,5.481012658227848,5.506329113924051,5.531645569620253,5.556962025316456,5.582278481012658,5.6075949367088604,5.632911392405063,5.658227848101266,5.6835443037974684,5.708860759493671,5.734177215189874,5.7594936708860756,5.784810126582278,5.810126582278481,5.8354430379746836,5.860759493670886,5.886075949367089,5.911392405063291,5.936708860759493,5.962025316455696,5.987341772151899,6.012658227848101,6.037974683544304,6.063291139240507,6.088607594936709,6.113924050632911,6.139240506329114,6.1645569620253164,6.189873417721519,6.215189873417722,6.240506329113924,6.265822784810126,6.291139240506329,6.3164556962025316,6.341772151898734,6.367088607594937,6.3924050632911396,6.417721518987342,6.443037974683544,6.468354430379747,6.493670886075949,6.518987341772152,6.544303797468355,6.5696202531645564,6.594936708860759,6.620253164556962,6.6455696202531644,6.670886075949367,6.69620253164557,6.7215189873417724,6.746835443037975,6.772151898734177,6.7974683544303796,6.822784810126582,6.848101265822785,6.8734177215189876,6.898734177215189,6.924050632911392,6.949367088607595,6.974683544303797,7.0,8.0,8.025316455696203,8.050632911392405,8.075949367088608,8.10126582278481,8.126582278481013,8.151898734177216,8.177215189873417,8.20253164556962,8.227848101265822,8.253164556962025,8.278481012658228,8.30379746835443,8.329113924050633,8.354430379746836,8.379746835443038,8.405063291139241,8.430379746835444,8.455696202531646,8.481012658227849,8.50632911392405,8.531645569620252,8.556962025316455,8.582278481012658,8.60759493670886,8.632911392405063,8.658227848101266,8.683544303797468,8.708860759493671,8.734177215189874,8.759493670886076,8.784810126582279,8.810126582278482,8.835443037974684,8.860759493670885,8.886075949367088,8.91139240506329,8.936708860759493,8.962025316455696,8.987341772151899,9.012658227848101,9.037974683544304,9.063291139240507,9.08860759493671,9.113924050632912,9.139240506329115,9.164556962025316,9.189873417721518,9.215189873417721,9.240506329113924,9.265822784810126,9.291139240506329,9.316455696202532,9.341772151898734,9.367088607594937,9.39240506329114,9.417721518987342,9.443037974683545,9.468354430379748,9.49367088607595,9.518987341772151,9.544303797468354,9.569620253164556,9.594936708860759,9.620253164556962,9.645569620253164,9.670886075949367,9.69620253164557,9.721518987341772,9.746835443037975,9.772151898734178,9.79746835443038,9.822784810126581,9.848101265822784,9.873417721518987,9.89873417721519,9.924050632911392,9.949367088607595,9.974683544303797,10.0],\n",
       "\"hwy\":[27.0,26.949367088607595,26.89873417721519,26.848101265822784,26.79746835443038,26.746835443037973,26.696202531645568,26.645569620253166,26.59493670886076,26.544303797468356,26.49367088607595,26.443037974683545,26.39240506329114,26.341772151898734,26.29113924050633,26.240506329113924,26.189873417721518,26.139240506329113,26.088607594936708,26.037974683544302,25.9873417721519,25.936708860759495,25.88607594936709,25.835443037974684,25.78481012658228,25.734177215189874,25.68354430379747,25.632911392405063,25.582278481012658,25.531645569620252,25.481012658227847,25.430379746835442,25.379746835443036,25.32911392405063,25.27848101265823,25.227848101265824,25.17721518987342,25.126582278481013,25.075949367088608,25.025316455696203,24.974683544303797,24.924050632911392,24.873417721518987,24.82278481012658,24.772151898734176,24.72151898734177,24.67088607594937,24.620253164556964,24.569620253164558,24.518987341772153,24.468354430379748,24.417721518987342,24.367088607594937,24.31645569620253,24.265822784810126,24.21518987341772,24.164556962025316,24.11392405063291,24.063291139240505,24.0126582278481,23.962025316455698,23.911392405063292,23.860759493670887,23.810126582278482,23.759493670886076,23.70886075949367,23.658227848101266,23.60759493670886,23.556962025316455,23.50632911392405,23.455696202531644,23.40506329113924,23.354430379746837,23.303797468354432,23.253164556962027,23.20253164556962,23.151898734177216,23.10126582278481,23.050632911392405,23.0,45.0,44.949367088607595,44.89873417721519,44.848101265822784,44.79746835443038,44.74683544303797,44.69620253164557,44.64556962025316,44.59493670886076,44.54430379746835,44.49367088607595,44.44303797468354,44.392405063291136,44.34177215189874,44.291139240506325,44.24050632911393,44.18987341772152,44.139240506329116,44.08860759493671,44.037974683544306,43.9873417721519,43.936708860759495,43.88607594936709,43.835443037974684,43.78481012658228,43.734177215189874,43.68354430379747,43.63291139240506,43.58227848101266,43.53164556962025,43.48101265822785,43.43037974683544,43.379746835443036,43.32911392405063,43.278481012658226,43.22784810126582,43.177215189873415,43.12658227848101,43.07594936708861,43.0253164556962,42.9746835443038,42.92405063291139,42.87341772151899,42.822784810126585,42.77215189873418,42.721518987341774,42.67088607594937,42.620253164556964,42.56962025316456,42.51898734177215,42.46835443037975,42.41772151898734,42.36708860759494,42.31645569620253,42.265822784810126,42.21518987341772,42.164556962025316,42.11392405063291,42.063291139240505,42.0126582278481,41.962025316455694,41.91139240506329,41.860759493670884,41.81012658227848,41.75949367088607,41.708860759493675,41.65822784810126,41.607594936708864,41.55696202531645,41.50632911392405,41.45569620253165,41.40506329113924,41.35443037974684,41.30379746835443,41.25316455696203,41.20253164556962,41.151898734177216,41.10126582278481,41.050632911392405,41.0,39.0,38.949367088607595,38.89873417721519,38.848101265822784,38.79746835443038,38.74683544303797,38.69620253164557,38.64556962025316,38.59493670886076,38.54430379746835,38.49367088607595,38.44303797468355,38.392405063291136,38.34177215189874,38.291139240506325,38.24050632911393,38.189873417721515,38.139240506329116,38.08860759493671,38.037974683544306,37.9873417721519,37.936708860759495,37.88607594936709,37.835443037974684,37.78481012658228,37.734177215189874,37.68354430379747,37.63291139240506,37.58227848101266,37.53164556962025,37.48101265822785,37.43037974683544,37.379746835443036,37.32911392405063,37.278481012658226,37.22784810126582,37.17721518987342,37.12658227848101,37.07594936708861,37.0253164556962,36.9746835443038,36.92405063291139,36.87341772151899,36.82278481012658,36.77215189873418,36.721518987341774,36.67088607594937,36.620253164556964,36.56962025316456,36.51898734177215,36.46835443037975,36.41772151898734,36.36708860759494,36.31645569620253,36.265822784810126,36.21518987341772,36.164556962025316,36.11392405063291,36.063291139240505,36.0126582278481,35.962025316455694,35.91139240506329,35.860759493670884,35.810126582278485,35.75949367088607,35.708860759493675,35.65822784810126,35.607594936708864,35.55696202531645,35.50632911392405,35.45569620253165,35.40506329113924,35.35443037974684,35.30379746835443,35.25316455696203,35.20253164556962,35.151898734177216,35.10126582278481,35.050632911392405,35.0,33.0,32.949367088607595,32.89873417721519,32.848101265822784,32.79746835443038,32.74683544303797,32.69620253164557,32.64556962025317,32.59493670886076,32.54430379746836,32.49367088607595,32.44303797468355,32.392405063291136,32.34177215189874,32.291139240506325,32.24050632911393,32.189873417721515,32.139240506329116,32.088607594936704,32.037974683544306,31.9873417721519,31.936708860759495,31.88607594936709,31.835443037974684,31.78481012658228,31.734177215189874,31.68354430379747,31.632911392405063,31.582278481012658,31.531645569620252,31.481012658227847,31.430379746835442,31.379746835443036,31.32911392405063,31.27848101265823,31.227848101265824,31.17721518987342,31.126582278481013,31.075949367088608,31.025316455696203,30.974683544303797,30.924050632911392,30.873417721518987,30.82278481012658,30.772151898734176,30.72151898734177,30.67088607594937,30.620253164556964,30.569620253164558,30.518987341772153,30.468354430379748,30.417721518987342,30.367088607594937,30.31645569620253,30.265822784810126,30.21518987341772,30.164556962025316,30.11392405063291,30.063291139240505,30.0126582278481,29.962025316455698,29.911392405063292,29.860759493670887,29.810126582278482,29.759493670886076,29.70886075949367,29.658227848101266,29.60759493670886,29.556962025316455,29.50632911392405,29.455696202531644,29.40506329113924,29.354430379746837,29.303797468354432,29.253164556962027,29.20253164556962,29.151898734177216,29.10126582278481,29.050632911392405,29.0]\n",
       "}\n",
       "}]\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"F23Qvp\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val df = mapOf(\n",
    "    \"displ\" to listOf(11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9, 10),\n",
    "    \"hwy\" to listOf(27, 25, 23, 45, 43, 41, 39, 37, 35, 33, 31, 29),\n",
    "    \"cyl\" to listOf(8, 8, 8, 4, 4, 4, 5, 5, 5, 6, 6, 6)\n",
    ")\n",
    "\n",
    "ggplot(df) { x=\"displ\"; y=\"hwy\" } + \n",
    "    geomPoint { color=asDiscrete(\"cyl\") } + \n",
    "    geomSmooth(method=\"lm\", size=1, se=false) { color=asDiscrete(\"cyl\") }"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "8e9a1e89-6624-4b9e-96be-414350dc5485",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"GhDJyh\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "\"x\":\"displ\",\n",
       "\"y\":\"hwy\"\n",
       "},\n",
       "\"data\":{\n",
       "\"cyl\":[8.0,8.0,8.0,4.0,4.0,4.0,5.0,5.0,5.0,6.0,6.0,6.0],\n",
       "\"displ\":[11.0,12.0,13.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0],\n",
       "\"hwy\":[27.0,25.0,23.0,45.0,43.0,41.0,39.0,37.0,35.0,33.0,31.0,29.0]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "\"color\":\"cyl\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"column\":\"cyl\",\n",
       "\"factor_levels\":[4,5,6,8,8.0,4.0,5.0,6.0]\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "\"color\":\"cyl\"\n",
       "},\n",
       "\"stat\":\"smooth\",\n",
       "\"se\":false,\n",
       "\"size\":1.0,\n",
       "\"method\":\"lm\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"smooth\",\n",
       "\"data_meta\":{\n",
       "\"mapping_annotations\":[{\n",
       "\"aes\":\"color\",\n",
       "\"annotation\":\"as_discrete\",\n",
       "\"parameters\":{\n",
       "\"label\":\"cyl\"\n",
       "}\n",
       "}]\n",
       "},\n",
       "\"data\":{\n",
       "\"cyl\":[8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0],\n",
       "\"displ\":[11.0,11.025316455696203,11.050632911392405,11.075949367088608,11.10126582278481,11.126582278481013,11.151898734177216,11.177215189873417,11.20253164556962,11.227848101265822,11.253164556962025,11.278481012658228,11.30379746835443,11.329113924050633,11.354430379746836,11.379746835443038,11.405063291139241,11.430379746835444,11.455696202531646,11.481012658227849,11.50632911392405,11.531645569620252,11.556962025316455,11.582278481012658,11.60759493670886,11.632911392405063,11.658227848101266,11.683544303797468,11.708860759493671,11.734177215189874,11.759493670886076,11.784810126582279,11.810126582278482,11.835443037974684,11.860759493670885,11.886075949367088,11.91139240506329,11.936708860759493,11.962025316455696,11.987341772151899,12.012658227848101,12.037974683544304,12.063291139240507,12.08860759493671,12.113924050632912,12.139240506329115,12.164556962025316,12.189873417721518,12.215189873417721,12.240506329113924,12.265822784810126,12.291139240506329,12.316455696202532,12.341772151898734,12.367088607594937,12.39240506329114,12.417721518987342,12.443037974683545,12.468354430379748,12.49367088607595,12.518987341772151,12.544303797468354,12.569620253164556,12.594936708860759,12.620253164556962,12.645569620253164,12.670886075949367,12.69620253164557,12.721518987341772,12.746835443037975,12.772151898734178,12.79746835443038,12.822784810126581,12.848101265822784,12.873417721518987,12.89873417721519,12.924050632911392,12.949367088607595,12.974683544303797,13.0,2.0,2.0253164556962027,2.050632911392405,2.0759493670886076,2.1012658227848102,2.1265822784810124,2.151898734177215,2.1772151898734178,2.2025316455696204,2.2278481012658227,2.2531645569620253,2.278481012658228,2.3037974683544302,2.329113924050633,2.3544303797468356,2.3797468354430378,2.4050632911392404,2.430379746835443,2.4556962025316453,2.481012658227848,2.5063291139240507,2.5316455696202533,2.5569620253164556,2.5822784810126582,2.607594936708861,2.632911392405063,2.6582278481012658,2.6835443037974684,2.708860759493671,2.7341772151898733,2.759493670886076,2.7848101265822782,2.810126582278481,2.8354430379746836,2.8607594936708862,2.8860759493670884,2.911392405063291,2.9367088607594938,2.962025316455696,2.9873417721518987,3.0126582278481013,3.037974683544304,3.0632911392405062,3.088607594936709,3.113924050632911,3.1392405063291138,3.1645569620253164,3.189873417721519,3.2151898734177218,3.240506329113924,3.2658227848101267,3.291139240506329,3.3164556962025316,3.3417721518987342,3.367088607594937,3.392405063291139,3.4177215189873418,3.443037974683544,3.4683544303797467,3.4936708860759493,3.518987341772152,3.5443037974683547,3.569620253164557,3.5949367088607596,3.620253164556962,3.6455696202531644,3.670886075949367,3.6962025316455698,3.7215189873417724,3.7468354430379747,3.772151898734177,3.7974683544303796,3.8227848101265822,3.848101265822785,3.8734177215189876,3.8987341772151898,3.9240506329113924,3.9493670886075947,3.9746835443037973,4.0,5.0,5.025316455696203,5.050632911392405,5.075949367088608,5.10126582278481,5.1265822784810124,5.151898734177215,5.177215189873418,5.2025316455696204,5.227848101265823,5.253164556962025,5.2784810126582276,5.30379746835443,5.329113924050633,5.3544303797468356,5.379746835443038,5.405063291139241,5.430379746835443,5.455696202531645,5.481012658227848,5.506329113924051,5.531645569620253,5.556962025316456,5.582278481012658,5.6075949367088604,5.632911392405063,5.658227848101266,5.6835443037974684,5.708860759493671,5.734177215189874,5.7594936708860756,5.784810126582278,5.810126582278481,5.8354430379746836,5.860759493670886,5.886075949367089,5.911392405063291,5.936708860759493,5.962025316455696,5.987341772151899,6.012658227848101,6.037974683544304,6.063291139240507,6.088607594936709,6.113924050632911,6.139240506329114,6.1645569620253164,6.189873417721519,6.215189873417722,6.240506329113924,6.265822784810126,6.291139240506329,6.3164556962025316,6.341772151898734,6.367088607594937,6.3924050632911396,6.417721518987342,6.443037974683544,6.468354430379747,6.493670886075949,6.518987341772152,6.544303797468355,6.5696202531645564,6.594936708860759,6.620253164556962,6.6455696202531644,6.670886075949367,6.69620253164557,6.7215189873417724,6.746835443037975,6.772151898734177,6.7974683544303796,6.822784810126582,6.848101265822785,6.8734177215189876,6.898734177215189,6.924050632911392,6.949367088607595,6.974683544303797,7.0,8.0,8.025316455696203,8.050632911392405,8.075949367088608,8.10126582278481,8.126582278481013,8.151898734177216,8.177215189873417,8.20253164556962,8.227848101265822,8.253164556962025,8.278481012658228,8.30379746835443,8.329113924050633,8.354430379746836,8.379746835443038,8.405063291139241,8.430379746835444,8.455696202531646,8.481012658227849,8.50632911392405,8.531645569620252,8.556962025316455,8.582278481012658,8.60759493670886,8.632911392405063,8.658227848101266,8.683544303797468,8.708860759493671,8.734177215189874,8.759493670886076,8.784810126582279,8.810126582278482,8.835443037974684,8.860759493670885,8.886075949367088,8.91139240506329,8.936708860759493,8.962025316455696,8.987341772151899,9.012658227848101,9.037974683544304,9.063291139240507,9.08860759493671,9.113924050632912,9.139240506329115,9.164556962025316,9.189873417721518,9.215189873417721,9.240506329113924,9.265822784810126,9.291139240506329,9.316455696202532,9.341772151898734,9.367088607594937,9.39240506329114,9.417721518987342,9.443037974683545,9.468354430379748,9.49367088607595,9.518987341772151,9.544303797468354,9.569620253164556,9.594936708860759,9.620253164556962,9.645569620253164,9.670886075949367,9.69620253164557,9.721518987341772,9.746835443037975,9.772151898734178,9.79746835443038,9.822784810126581,9.848101265822784,9.873417721518987,9.89873417721519,9.924050632911392,9.949367088607595,9.974683544303797,10.0],\n",
       "\"hwy\":[27.0,26.949367088607595,26.89873417721519,26.848101265822784,26.79746835443038,26.746835443037973,26.696202531645568,26.645569620253166,26.59493670886076,26.544303797468356,26.49367088607595,26.443037974683545,26.39240506329114,26.341772151898734,26.29113924050633,26.240506329113924,26.189873417721518,26.139240506329113,26.088607594936708,26.037974683544302,25.9873417721519,25.936708860759495,25.88607594936709,25.835443037974684,25.78481012658228,25.734177215189874,25.68354430379747,25.632911392405063,25.582278481012658,25.531645569620252,25.481012658227847,25.430379746835442,25.379746835443036,25.32911392405063,25.27848101265823,25.227848101265824,25.17721518987342,25.126582278481013,25.075949367088608,25.025316455696203,24.974683544303797,24.924050632911392,24.873417721518987,24.82278481012658,24.772151898734176,24.72151898734177,24.67088607594937,24.620253164556964,24.569620253164558,24.518987341772153,24.468354430379748,24.417721518987342,24.367088607594937,24.31645569620253,24.265822784810126,24.21518987341772,24.164556962025316,24.11392405063291,24.063291139240505,24.0126582278481,23.962025316455698,23.911392405063292,23.860759493670887,23.810126582278482,23.759493670886076,23.70886075949367,23.658227848101266,23.60759493670886,23.556962025316455,23.50632911392405,23.455696202531644,23.40506329113924,23.354430379746837,23.303797468354432,23.253164556962027,23.20253164556962,23.151898734177216,23.10126582278481,23.050632911392405,23.0,45.0,44.949367088607595,44.89873417721519,44.848101265822784,44.79746835443038,44.74683544303797,44.69620253164557,44.64556962025316,44.59493670886076,44.54430379746835,44.49367088607595,44.44303797468354,44.392405063291136,44.34177215189874,44.291139240506325,44.24050632911393,44.18987341772152,44.139240506329116,44.08860759493671,44.037974683544306,43.9873417721519,43.936708860759495,43.88607594936709,43.835443037974684,43.78481012658228,43.734177215189874,43.68354430379747,43.63291139240506,43.58227848101266,43.53164556962025,43.48101265822785,43.43037974683544,43.379746835443036,43.32911392405063,43.278481012658226,43.22784810126582,43.177215189873415,43.12658227848101,43.07594936708861,43.0253164556962,42.9746835443038,42.92405063291139,42.87341772151899,42.822784810126585,42.77215189873418,42.721518987341774,42.67088607594937,42.620253164556964,42.56962025316456,42.51898734177215,42.46835443037975,42.41772151898734,42.36708860759494,42.31645569620253,42.265822784810126,42.21518987341772,42.164556962025316,42.11392405063291,42.063291139240505,42.0126582278481,41.962025316455694,41.91139240506329,41.860759493670884,41.81012658227848,41.75949367088607,41.708860759493675,41.65822784810126,41.607594936708864,41.55696202531645,41.50632911392405,41.45569620253165,41.40506329113924,41.35443037974684,41.30379746835443,41.25316455696203,41.20253164556962,41.151898734177216,41.10126582278481,41.050632911392405,41.0,39.0,38.949367088607595,38.89873417721519,38.848101265822784,38.79746835443038,38.74683544303797,38.69620253164557,38.64556962025316,38.59493670886076,38.54430379746835,38.49367088607595,38.44303797468355,38.392405063291136,38.34177215189874,38.291139240506325,38.24050632911393,38.189873417721515,38.139240506329116,38.08860759493671,38.037974683544306,37.9873417721519,37.936708860759495,37.88607594936709,37.835443037974684,37.78481012658228,37.734177215189874,37.68354430379747,37.63291139240506,37.58227848101266,37.53164556962025,37.48101265822785,37.43037974683544,37.379746835443036,37.32911392405063,37.278481012658226,37.22784810126582,37.17721518987342,37.12658227848101,37.07594936708861,37.0253164556962,36.9746835443038,36.92405063291139,36.87341772151899,36.82278481012658,36.77215189873418,36.721518987341774,36.67088607594937,36.620253164556964,36.56962025316456,36.51898734177215,36.46835443037975,36.41772151898734,36.36708860759494,36.31645569620253,36.265822784810126,36.21518987341772,36.164556962025316,36.11392405063291,36.063291139240505,36.0126582278481,35.962025316455694,35.91139240506329,35.860759493670884,35.810126582278485,35.75949367088607,35.708860759493675,35.65822784810126,35.607594936708864,35.55696202531645,35.50632911392405,35.45569620253165,35.40506329113924,35.35443037974684,35.30379746835443,35.25316455696203,35.20253164556962,35.151898734177216,35.10126582278481,35.050632911392405,35.0,33.0,32.949367088607595,32.89873417721519,32.848101265822784,32.79746835443038,32.74683544303797,32.69620253164557,32.64556962025317,32.59493670886076,32.54430379746836,32.49367088607595,32.44303797468355,32.392405063291136,32.34177215189874,32.291139240506325,32.24050632911393,32.189873417721515,32.139240506329116,32.088607594936704,32.037974683544306,31.9873417721519,31.936708860759495,31.88607594936709,31.835443037974684,31.78481012658228,31.734177215189874,31.68354430379747,31.632911392405063,31.582278481012658,31.531645569620252,31.481012658227847,31.430379746835442,31.379746835443036,31.32911392405063,31.27848101265823,31.227848101265824,31.17721518987342,31.126582278481013,31.075949367088608,31.025316455696203,30.974683544303797,30.924050632911392,30.873417721518987,30.82278481012658,30.772151898734176,30.72151898734177,30.67088607594937,30.620253164556964,30.569620253164558,30.518987341772153,30.468354430379748,30.417721518987342,30.367088607594937,30.31645569620253,30.265822784810126,30.21518987341772,30.164556962025316,30.11392405063291,30.063291139240505,30.0126582278481,29.962025316455698,29.911392405063292,29.860759493670887,29.810126582278482,29.759493670886076,29.70886075949367,29.658227848101266,29.60759493670886,29.556962025316455,29.50632911392405,29.455696202531644,29.40506329113924,29.354430379746837,29.303797468354432,29.253164556962027,29.20253164556962,29.151898734177216,29.10126582278481,29.050632911392405,29.0]\n",
       "}\n",
       "}]\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"GhDJyh\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ggplot(df) { x=\"displ\"; y=\"hwy\" } + \n",
    "    geomPoint { color=asDiscrete(\"cyl\", levels = listOf(4, 5, 6, 8)) } + \n",
    "    geomSmooth(method=\"lm\", size=1, se=false) { color=asDiscrete(\"cyl\") }"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4c5456b5-8291-4243-b366-b15c811b1579",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Kotlin",
   "language": "kotlin",
   "name": "kotlin"
  },
  "language_info": {
   "codemirror_mode": "text/x-kotlin",
   "file_extension": ".kt",
   "mimetype": "text/x-kotlin",
   "name": "kotlin",
   "nbconvert_exporter": "",
   "pygments_lexer": "kotlin",
   "version": "1.9.23"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
